<template>
  <div>
    <span class="ysdh_spin">
      <a-spin tip="Loading..." :spinning="spinning" />
    </span>
    <div class="ddkd-title">物流运行轨迹</div>
    <div class="ddkd-container">
      <div v-if="flag">
        <a-timeline mode="alternate">
          <a-timeline-item
            v-for="(item,i) in mailDataList"
            :key="i"
          >{{item.AcceptStation}} 【{{item.action_msg}}】</a-timeline-item>
        </a-timeline>
      </div>
      <div v-else>暂无物流运动轨迹</div>
    </div>
  </div>
</template>

<script type="text/javascript">
import qs from "qs";
export default {
  data() {
    return {
      // //获取物流运单号:
      // ydh:'',
      // //获取物流公司编码:
      // wlbm:'',
      flag: true,
      spinning: true,
      mailDataList: []
    };
  },
  methods: {
    getMailbbl() {
      this.axios
        .post(
          //
          "order/getKdData.php", //快递鸟---
          // "order/logisticsPath.php",
          qs.stringify({
            //   shipperCode:  wlbm,// 快递鸟---
            //   logisticCode:ydh,// 快递鸟---

            sqdwid: this.$parent.wuldata.gyssqdwid,
            SQDHDH: this.$parent.wuldata.SQDHDH,
            openid: this.$parent.wuldata.openid,
            YUNSHUFSBM: this.$parent.wuldata.YUNSHUFSBM,
            // YUNSHUFSBM: "ZTO",
            YUNSHUDH: this.$parent.wuldata.YUNSHUDH
            // YUNSHUDH: "78137665605206"
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.Traces.length) {
            this.spinning = false;
            this.mailDataList = res.data.Traces;
          } else {
            this.flag = false;
            this.spinning = false;
            // this.mailDataList = "暂无物流信息";
          }
        });
    },
    getMaillz() {
      this.axios
        .post(
          //
          // "order/getKdData.php",  快递鸟---
          "order/logisticsPath.php",
          qs.stringify({
            //   shipperCode:  wlbm,// 快递鸟---
            //   logisticCode:ydh,// 快递鸟---

            sqdwid: this.$store.state.bbl_sqdwid,
            SQDHDH: this.$parent.wuldata.SQDHDH,
            openid: this.$parent.wuldata.openid,
            YUNSHUFSBM: this.$parent.wuldata.YUNSHUFSBM,
            YUNSHUDH: this.$parent.wuldata.YUNSHUDH
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.spinning = false;

            if (res.data.result.path_item_num) {
              this.mailDataList = res.data.result.path_item_list;
            } else {
              this.flag = false;

              this.mailDataList = "暂无物流信息";
            }
          }
        });
    },
    getMailData() {
      console.log(this.$parent.wuldata);
      if (this.$parent.wuldata.gyssqdwid == "80279") {
        this.getMaillz();
      } else {
        this.getMailbbl();
      }
    }
  },
  created() {
    //获取物流轨迹
    this.getMailData();
  }
};
</script>

<style type="text/css">
.ysdh_spin {
  float: right;
  position: relative;
  right: 307px;
  top: 250px;
  z-index: 9999;
}
.ddkd-title {
  height: 45px;
  line-height: 45px;
  border-bottom: 1px solid #ccc;
  font-size: 15px;
  font-weight: bold;
}
.ddkd-container {
  width: 100%;
  padding: 20px;
}
</style>